using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace FastFoodToNight.Models.Mapping
{
    public class DonDatHangMap : EntityTypeConfiguration<DonDatHang>
    {
        public DonDatHangMap()
        {
            // Primary Key
            this.HasKey(t => t.madondathang);

            // Properties
            this.Property(t => t.duong)
                .HasMaxLength(50);

            this.Property(t => t.phuong)
                .HasMaxLength(50);

            this.Property(t => t.quan)
                .HasMaxLength(50);

            this.Property(t => t.sodienthoai)
                .HasMaxLength(20);

            // Table & Column Mappings
            this.ToTable("DonDatHang");
            this.Property(t => t.madondathang).HasColumnName("madondathang");
            this.Property(t => t.ngaylap).HasColumnName("ngaylap");
            this.Property(t => t.sonha).HasColumnName("sonha");
            this.Property(t => t.duong).HasColumnName("duong");
            this.Property(t => t.phuong).HasColumnName("phuong");
            this.Property(t => t.quan).HasColumnName("quan");
            this.Property(t => t.sodienthoai).HasColumnName("sodienthoai");
            this.Property(t => t.sotien).HasColumnName("sotien");
            this.Property(t => t.userid).HasColumnName("userid");

            // Relationships
            this.HasOptional(t => t.NguoiDung)
                .WithMany(t => t.DonDatHangs)
                .HasForeignKey(d => d.userid);

        }
    }
}
